package com.alquimia.identityaccess.application.events.user;

import com.alquimia.identityaccess.application.events.UpdatedEvent;
import com.alquimia.identityaccess.domain.model.User;

/**
 * Created by Ivo on 16/07/2014.
 */
public class UserPasswordUpdatedEvent extends UpdatedEvent {

    private String userId;
    private String password;

    public UserPasswordUpdatedEvent(User aUser) {
        super();

        this.initializeFrom(aUser);
    }

    public UserPasswordUpdatedEvent(String aUserId) {
        super();

        this.userId = aUserId;
    }

    public String getUserId() {
        return userId;
    }

    public String getPassword() {
        return password;
    }

    private void initializeFrom(User aUser) {
        this.password = aUser.password();
        this.userId = aUser.userId().id().toString();
    }

    public static UserPasswordUpdatedEvent notFound(String aUserId) {
        UserPasswordUpdatedEvent userPasswordUpdatedEvent = new UserPasswordUpdatedEvent(aUserId);
        userPasswordUpdatedEvent.entityFound = false;
        return userPasswordUpdatedEvent;
    }


}
